# Copyright 2025 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""Generate data for test."""
import numpy as np

def get_init_params(input_size, output_size):
    # Generate initialization parameters
    np.random.seed(42)
    weight_shape = (input_size, output_size)
    return {
        "inputs": 0.01 * np.random.randn(2, 2, input_size),
        "weight_tensor_input": 0.01 * np.random.randn(*weight_shape),
        "weight": 0.01 * np.random.randn(*weight_shape),
        "bias": 0.01 * np.random.randn(output_size)
    }

def get_golden() -> dict[str, np.ndarray]:
    """Generate golden data for test."""
    output_only = np.array(
        [[[-3.14594596e-04, 1.02819606e-04, 1.06698259e-04, -1.79944502e-04,
           -5.23609750e-04, 4.20684984e-04, 6.37556717e-04, 4.45676706e-04,
           -1.74341229e-04, -1.25949562e-03, -7.39499112e-04, -6.99614582e-04,
           1.96601453e-04, 3.38830199e-04, -3.00779793e-04, 9.96418166e-05,
           -6.77391421e-04, 5.66220144e-04, -2.77063024e-04, 2.15865890e-04,
           8.22328904e-04, 3.52134492e-04, 8.06517492e-05, -8.23923037e-05,
           -6.89131150e-04, 1.21067883e-03, 6.41837076e-04, -8.48301424e-05,
           -1.92160558e-04, -3.23000917e-04, -2.30574544e-04, 4.73301072e-04],
          [-1.02678849e-03, -1.43774523e-04, -1.37408101e-03, 3.50416929e-04,
           1.08573229e-04, 1.86605525e-04, 1.86693331e-04, -3.71105387e-04,
           -1.63501274e-04, -2.08868369e-04, -3.51626601e-04, 2.78422871e-04,
           -4.78206930e-04, -2.72649078e-04, 3.53128009e-04, -3.99030832e-04,
           -7.25796679e-04, -2.49636185e-04, -5.73750644e-04, 4.13701164e-05,
           4.68608865e-04, 1.56536815e-04, -6.21853280e-04, 3.09688767e-04,
           1.41066528e-04, -1.27949635e-03, -3.61160928e-04, -5.39806148e-04,
           3.58645804e-04, 5.33616228e-04, 6.00588275e-04, -2.88258423e-04]],
         [[2.41685790e-04, -5.24524148e-05, 3.85142514e-04, 1.04925050e-04,
           -4.13992821e-04, 1.91213359e-04, -1.46060091e-04, 4.05039522e-04,
           -1.04783012e-05, 9.52528673e-04, -1.81338313e-04, -5.67879702e-04,
           -1.26967672e-04, -1.34912116e-04, -2.08122001e-04, 3.57962504e-04,
           -1.07920356e-03, -4.03459217e-06, -7.95009604e-04, 4.52377280e-04,
           -8.97330028e-05, 7.64255819e-04, -6.46131171e-04, 1.58582494e-04,
           8.89709161e-04, 5.11146845e-06, 5.90574287e-04, -7.00259116e-04,
           -6.10762974e-04, 7.50950358e-06, -6.04420726e-04, 3.24779161e-04],
          [-1.87654397e-04, -7.18139403e-04, 8.89678951e-04, 5.54114195e-06,
           1.95368790e-04, 2.64798553e-04, -2.46778713e-04, 2.02851923e-04,
           1.96214860e-05, 1.47514642e-04, 1.43178343e-03, 8.71199067e-04,
           -5.53342397e-04, 1.80885996e-04, 5.44524846e-05, 7.90347112e-04,
           -2.75532628e-04, 2.03682299e-04, -1.58973453e-05, 8.68022849e-04,
           -1.21149395e-04, -6.68301713e-04, 3.76890530e-04, 1.97606176e-04,
           -4.20407043e-04, -1.72288346e-04, -4.37892420e-04, 4.79541835e-04,
           5.53227263e-04, -2.14818399e-04, 2.77209096e-04, -4.15213202e-04]]])
    output_with_bias = np.array(
        [[[-1.63912047e-02, 1.95022544e-03, 2.03427598e-02, -1.11946058e-04,
           -2.42400006e-03, -3.15376930e-03, -1.16635999e-03, 1.41741615e-02,
           -2.22929604e-02, 1.40748415e-02, -1.49790710e-02, -3.36613785e-03,
           -4.09584306e-03, 6.22436265e-03, -1.62820239e-02, 4.72136820e-03,
           1.95657052e-02, -1.30655197e-02, 1.61999871e-03, -6.40395610e-03,
           5.08120097e-03, 5.43612288e-04, -6.33421727e-03, 4.79633082e-03,
           1.73543505e-02, -6.98359101e-04, 7.83941615e-03, -1.30175604e-02,
           -9.75652412e-03, 4.40106215e-03, 1.46105858e-02, 4.02943464e-03],
          [-1.71033982e-02, 1.70363125e-03, 188619.811e-07, 4.18415380e-04,
           -1.79181714e-03, -3.38784861e-03, -1.61722349e-03, 1.33573795e-02,
           -2.22821198e-02, 1.51254684e-02, -1.45911984e-02, -2.38810037e-03,
           -4.77065146e-03, 5.61288372e-03, -1.56281162e-02, 4.22269572e-03,
           1.95173007e-02, -1.38813760e-02, 1.32331112e-03, -6.57845149e-03,
           4.72748093e-03, 3.48014582e-04, -7.03672227e-03, 5.18841203e-03,
           1.81845482e-02, -3.18853417e-03, 6.83641853e-03, -1.34725356e-02,
           -9.20571759e-03, 5.25767915e-03, 1.54417492e-02, 3.26787494e-03]],
         [[-1.58349238e-02, 1.79495336e-03, 2.06212047e-02, 1.72923494e-04,
           -2.31438316e-03, -3.38324090e-03, -1.94997690e-03, 1.41335241e-02,
           -2.21290961e-02, 1.62868649e-02, -1.44209107e-02, -3.23440298e-03,
           -4.41941200e-03, 5.75062027e-03, -1.61893666e-02, 4.97968914e-03,
           1.91638935e-02, -1.36357741e-02, 1.10205216e-03, -6.16744440e-03,
           4.16913908e-03, 9.55733587e-04, -7.06099998e-03, 5.03730541e-03,
           1.89331900e-02, -1.90392649e-03, 7.78815383e-03, -1.36329886e-02,
           -1.01751266e-02, 4.73157270e-03, 1.42367398e-02, 3.88091267e-03],
          [-1.62642635e-02, 1.12926634e-03, 2.11257413e-02, 7.35395879e-05,
           -1.70502160e-03, -3.30965570e-03, -2.05069548e-03, 1.39313368e-02,
           -2.20989976e-02, 1.54818520e-02, -1.28077883e-02, -1.79532415e-03,
           -4.84578684e-03, 6.06641872e-03, -1.59267914e-02, 5.41207381e-03,
           1.99675653e-02, -1.34280575e-02, 1.88116438e-03, -5.75179886e-03,
           4.13772278e-03, -4.76823945e-04, -6.03797846e-03, 5.07632922e-03,
           1.76230744e-02, -2.08132621e-03, 6.75968686e-03, -1.24531882e-02,
           -9.01113637e-03, 4.50924458e-03, 1.51183698e-02, 3.14092031e-03]]])
    output_use_weight = np.array(
        [[[3.35529010e-04, -1.47874016e-05, -4.75405075e-04, -7.19375676e-04,
           -7.90929073e-04, -5.98629005e-04, 1.08718954e-03, -3.74901392e-05,
           -2.26418153e-04, 1.09124801e-03, 1.57300310e-04, 1.28651809e-05,
           1.13083620e-03, -1.06586944e-04, 1.20649886e-04, -6.39138860e-04,
           -1.23379228e-03, -8.65723006e-04, 9.62456179e-05, 5.16220927e-04,
           -4.14076094e-05, -5.85001369e-04, 4.78591333e-04, -7.01963552e-04,
           -2.77684099e-04, 3.44725326e-04, -6.93066067e-06, 4.95527311e-05,
           -1.40422460e-04, -3.98345495e-04, -9.71202535e-05, -9.24556982e-04],
          [-2.47821707e-04, -4.61651478e-04, -2.53645732e-04, 2.49482575e-04,
           -6.82883910e-05, 8.15083331e-05, -4.59589035e-04, 6.00856089e-04,
           2.57081672e-04, -7.55110872e-04, -9.04858462e-04, 3.44490836e-04,
           2.90899305e-04, 1.79447437e-04, -9.49880050e-05, 1.92283711e-04,
           7.19159434e-04, -1.33688718e-05, -7.99079309e-04, -1.82479795e-04,
           -4.41873504e-04, 2.06791941e-04, 3.52486968e-04, -4.23199119e-04,
           -3.89948837e-04, 3.79206176e-04, -3.41333543e-05, 6.76435520e-05,
           6.65849191e-04, 1.04227487e-03, -4.22581797e-05, 5.89037663e-04]],
         [[-6.86149520e-04, -2.80263557e-05, -3.43566877e-04, -8.30309349e-04,
           -1.10143668e-03, -3.13304423e-04, 4.65871446e-04, 2.66427087e-04,
           -1.06453910e-04, 1.39165227e-03, -6.21938205e-04, -4.25184116e-04,
           3.48860689e-04, 1.44734411e-04, 1.27503136e-03, -3.88117594e-04,
           3.93346389e-04, 1.02808837e-04, -3.65054642e-04, -2.74257007e-04,
           7.99718327e-05, 5.19217458e-04, -2.34783598e-04, -9.92397894e-04,
           1.57460468e-04, 1.64726094e-04, 3.65310436e-04, -2.03588672e-04,
           4.03223938e-04, 7.73400243e-04, -6.80625788e-04, 2.48473134e-05],
          [1.01744139e-03, -5.24415402e-04, 8.34569975e-04, 8.29289143e-04,
           3.96900577e-04, 2.80026288e-04, -5.35133993e-04, 5.61153982e-04,
           1.52959372e-04, -2.92166631e-04, -2.71258265e-04, -6.03992026e-04,
           -2.59631546e-04, -2.54682673e-04, 4.86006931e-04, -2.89768999e-04,
           -1.07088243e-04, 5.85543690e-04, -3.45947454e-04, 9.19739483e-04,
           4.60906827e-04, 4.23900783e-04, -1.49478577e-03, -2.59319495e-04,
           1.00371646e-04, -3.94257484e-04, -4.91266896e-04, -6.55193115e-04,
           -1.97119298e-04, -5.12892730e-04, -8.67994560e-04, -1.68439568e-04]]])
    output_bias = np.array(
        [-1.60766095e-02, 1.84740580e-03, 2.02360619e-02, 6.79984441e-05,
         -1.90039037e-03, -3.57445423e-03, -1.80391676e-03, 1.37284845e-02,
         -2.21186187e-02, 1.53343370e-02, -1.42395720e-02, -2.66652321e-03,
         -4.29244433e-03, 5.88553259e-03, -1.59812439e-02, 4.62172646e-03,
         2.02430971e-02, -1.36317397e-02, 1.89706171e-03, -6.61982177e-03,
         4.25887201e-03, 1.91477768e-04, -6.41486887e-03, 4.87872306e-03,
         1.80434808e-02, -1.90903794e-03, 7.19757937e-03, -1.29327299e-02,
         -9.56436340e-03, 4.72406298e-03, 1.48411607e-02, 3.55613348e-03])
    return {
        "output_only": output_only,
        "output_with_bias": output_with_bias,
        "output_use_weight": output_use_weight,
        "output_bias": output_bias
    }

def get_gpu_datas() -> dict[str, np.ndarray]:
    """Generate gpu data for test."""
    output_only = np.array(
        [[[-3.14712524e-04, 1.01566315e-04, 1.08718872e-04, -1.80244446e-04,
           -5.22613525e-04, 4.21524048e-04, 6.37054443e-04, 4.46319580e-04,
           -1.74522400e-04, -1.25885010e-03, -7.40051270e-04, -7.01904297e-04,
           1.98364258e-04, 3.37600708e-04, -3.01361084e-04, 9.96589661e-05,
           -6.79016113e-04, 5.68389893e-04, -2.76565552e-04, 2.16484070e-04,
           8.23974609e-04, 3.50952148e-04, 8.05854797e-05, -8.15391541e-05,
           -6.90460205e-04, 1.21307373e-03, 6.40869141e-04, -8.34465027e-05,
           -1.93595886e-04, -3.22341919e-04, -2.30789185e-04, 4.71115112e-04],
          [-1.02996826e-03, -1.42097473e-04, -1.37329102e-03, 3.50952148e-04,
           1.07765198e-04, 1.86920166e-04, 1.85966492e-04, -3.70025635e-04,
           -1.62124634e-04, -2.08854675e-04, -3.52859497e-04, 2.78472900e-04,
           -4.78744507e-04, -2.72750854e-04, 3.54766846e-04, -3.98635864e-04,
           -7.24792480e-04, -2.49862671e-04, -5.72204590e-04, 4.07695770e-05,
           4.69207764e-04, 1.55448914e-04, -6.21795654e-04, 3.10897827e-04,
           1.40190125e-04, -1.28173828e-03, -3.62396240e-04, -5.41687012e-04,
           3.60488892e-04, 5.34057617e-04, 6.02722168e-04, -2.86102295e-04]],
         [[2.43186951e-04, -5.48362732e-05, 3.85284424e-04, 1.05381012e-04,
           -4.13894653e-04, 1.91688538e-04, -1.45912170e-04, 4.06265259e-04,
           -1.13248825e-05, 9.49859619e-04, -1.80244446e-04, -5.68389893e-04,
           -1.25885010e-04, -1.34468079e-04, -2.08854675e-04, 3.56674194e-04,
           -1.07574463e-03, -2.65240669e-06, -7.93457031e-04, 4.52041626e-04,
           -9.01222229e-05, 7.62939453e-04, -6.44683838e-04, 1.58309937e-04,
           8.88824463e-04, 3.93390656e-06, 5.91278076e-04, -6.98089600e-04,
           -6.10351562e-04, 7.59959221e-06, -6.02722168e-04, 3.24249268e-04],
          [-1.87873840e-04, -7.17163086e-04, 8.88824463e-04, 4.11272049e-06,
           1.95503235e-04, 2.67028809e-04, -2.46047974e-04, 2.01225281e-04,
           2.06232071e-05, 1.48773193e-04, 1.43432617e-03, 8.73565674e-04,
           -5.53131104e-04, 1.80244446e-04, 5.50746918e-05, 7.89642334e-04,
           -2.78472900e-04, 2.04086304e-04, -1.48415565e-05, 8.69750977e-04,
           -1.20162964e-04, -6.67572021e-04, 3.75747681e-04, 1.98364258e-04,
           -4.21524048e-04, -1.71661377e-04, -4.38690186e-04, 4.78744507e-04,
           5.53131104e-04, -2.15530396e-04, 2.76565552e-04, -4.13894653e-04]]])
    output_with_bias = np.array(
        [[[-1.64794922e-02, 1.94549561e-03, 2.03857422e-02, -1.12056732e-04,
           -2.42614746e-03, -3.14331055e-03, -1.15966797e-03, 1.41601562e-02,
           -2.22167969e-02, 1.40380859e-02, -1.49536133e-02, -3.37219238e-03,
           -4.08935547e-03, 6.22558594e-03, -1.62353516e-02, 4.69970703e-03,
           1.95312500e-02, -1.30615234e-02, 1.62506104e-03, -6.40869141e-03,
           5.09643555e-03, 5.41687012e-04, -6.31713867e-03, 4.79125977e-03,
           1.73339844e-02, -6.94274902e-04, 7.81250000e-03, -1.30004883e-02,
           -9.76562500e-03, 4.39453125e-03, 1.45874023e-02, 4.02832031e-03],
          [-1.70898438e-02, 1.70135498e-03, 1.89208984e-02, 4.19616699e-04,
           -1.79290771e-03, -3.38745117e-03, -1.61743164e-03, 1.33666992e-02,
           -2.22167969e-02, 1.51367188e-02, -1.45874023e-02, -2.39562988e-03,
           -4.79125977e-03, 5.61523438e-03, -1.56250000e-02, 4.21142578e-03,
           1.95312500e-02, -1.38549805e-02, 1.32751465e-03, -6.59179688e-03,
           4.73022461e-03, 3.47137451e-04, -7.01904297e-03, 5.18798828e-03,
           1.81884766e-02, -3.18908691e-03, 6.83593750e-03, -1.34887695e-02,
           -9.21630859e-03, 5.24902344e-03, 1.54418945e-02, 3.26538086e-03]],
         [[-1.58691406e-02, 1.79290771e-03, 2.06298828e-02, 1.73568726e-04,
           -2.31933594e-03, -3.37219238e-03, -1.94549561e-03, 1.41601562e-02,
           -2.20947266e-02, 1.62353516e-02, -1.44042969e-02, -3.23486328e-03,
           -4.42504883e-03, 5.76782227e-03, -1.62353516e-02, 4.97436523e-03,
           1.91650391e-02, -1.36108398e-02, 1.10626221e-03, -6.16455078e-03,
           4.18090820e-03, 9.53674316e-04, -7.04956055e-03, 5.03540039e-03,
           1.89208984e-02, -1.89971924e-03, 7.78198242e-03, -1.36108398e-02,
           -1.01928711e-02, 4.73022461e-03, 1.42211914e-02, 3.87573242e-03],
          [-1.63574219e-02, 1.12915039e-03, 2.11181641e-02, 7.24792480e-05,
           -1.70135498e-03, -3.29589844e-03, -2.04467773e-03, 1.39160156e-02,
           -2.20947266e-02, 1.54418945e-02, -1.28173828e-02, -1.80053711e-03,
           -4.85229492e-03, 6.07299805e-03, -1.59912109e-02, 5.40161133e-03,
           2.00195312e-02, -1.34277344e-02, 1.88446045e-03, -5.73730469e-03,
           4.15039062e-03, -4.76837158e-04, -6.04248047e-03, 5.06591797e-03,
           1.77001953e-02, -2.07519531e-03, 6.77490234e-03, -1.24511719e-02,
           -9.03320312e-03, 4.51660156e-03, 1.51367188e-02, 3.14331055e-03]]])
    output_use_weight = np.array(
        [[[3.35693359e-04, -1.51991844e-05, -4.74929810e-04, -7.20977783e-04,
           -7.93457031e-04, -5.98907471e-04, 1.08337402e-03, -3.67164612e-05,
           -2.25067139e-04, 1.09100342e-03, 1.56402588e-04, 1.24573708e-05,
           1.12915039e-03, -1.05857849e-04, 1.20162964e-04, -6.40869141e-04,
           -1.23596191e-03, -8.65936279e-04, 9.63211060e-05, 5.14984131e-04,
           -4.07695770e-05, -5.83648682e-04, 4.76837158e-04, -7.01904297e-04,
           -2.76565552e-04, 3.45230103e-04, -5.27501106e-06, 4.81605530e-05,
           -1.41143799e-04, -3.98635864e-04, -9.77516174e-05, -9.23156738e-04],
          [-2.47955322e-04, -4.61578369e-04, -2.55584717e-04, 2.49862671e-04,
           -6.81877136e-05, 8.24928284e-05, -4.59671021e-04, 5.98907471e-04,
           2.55584717e-04, -7.55310059e-04, -9.04083252e-04, 3.43322754e-04,
           2.89916992e-04, 1.79290771e-04, -9.48905945e-05, 1.91688538e-04,
           7.17163086e-04, -1.52587891e-05, -8.01086426e-04, -1.83105469e-04,
           -4.40597534e-04, 2.06947327e-04, 3.52859497e-04, -4.23431396e-04,
           -3.89099121e-04, 3.79562378e-04, -3.38554382e-05, 6.72340393e-05,
           6.67572021e-04, 1.03759766e-03, -4.33921814e-05, 5.87463379e-04]],
         [[-6.86645508e-04, -2.84910202e-05, -3.41415405e-04, -8.31604004e-04,
           -1.10626221e-03, -3.12805176e-04, 4.65393066e-04, 2.67028809e-04,
           -1.06334686e-04, 1.38854980e-03, -6.21795654e-04, -4.25338745e-04,
           3.49044800e-04, 1.44958496e-04, 1.27410889e-03, -3.89099121e-04,
           3.94821167e-04, 1.02043152e-04, -3.64303589e-04, -2.76565552e-04,
           7.96318054e-05, 5.18798828e-04, -2.34603882e-04, -9.91821289e-04,
           1.57356262e-04, 1.64031982e-04, 3.66210938e-04, -2.03132629e-04,
           4.02450562e-04, 7.70568848e-04, -6.82830811e-04, 2.33650208e-05],
          [1.01470947e-03, -5.26428223e-04, 8.35418701e-04, 8.31604004e-04,
           3.98635864e-04, 2.80380249e-04, -5.34057617e-04, 5.60760498e-04,
           1.51634216e-04, -2.93731689e-04, -2.70843506e-04, -6.02722168e-04,
           -2.59399414e-04, -2.53677368e-04, 4.86373901e-04, -2.89916992e-04,
           -1.07765198e-04, 5.87463379e-04, -3.43322754e-04, 9.19342041e-04,
           4.59671021e-04, 4.23431396e-04, -1.49536133e-03, -2.59399414e-04,
           9.91821289e-05, -3.94821167e-04, -4.92095947e-04, -6.56127930e-04,
           -1.96456909e-04, -5.11169434e-04, -8.65936279e-04, -1.68800354e-04]]])
    output_bias = np.array(
        [-1.6113281e-02, 1.8463135e-03, 2.0263672e-02, 6.8187714e-05,
         -1.8997192e-03, -3.5705566e-03, -1.8005371e-03, 1.3732910e-02,
         -2.2094727e-02, 1.5319824e-02, -1.4221191e-02, -2.6702881e-03,
         -4.3029785e-03, 5.8898926e-03, -1.5991211e-02, 4.6081543e-03,
         2.0263672e-02, -1.3610840e-02, 1.8997192e-03, -6.6223145e-03,
         4.2724609e-03, 1.9168854e-04, -6.4086914e-03, 4.8828125e-03,
         1.8066406e-02, -1.9073486e-03, 7.2021484e-03, -1.2939453e-02,
         -9.5825195e-03, 4.7302246e-03, 1.4831543e-02, 3.5552979e-03])
    return {
        "output_only": output_only,
        "output_with_bias": output_with_bias,
        "output_use_weight": output_use_weight,
        "output_bias": output_bias
    }

GOLDEN_DATA = get_golden()
GPU_DATA = get_gpu_datas()
